package com.zhiyou.crowdfunding.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhiyou.crowdfunding.bean.User;
import com.zhiyou.crowdfunding.mapper.UserMapper;
import com.zhiyou.crowdfunding.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jyf
 * @since 2022-05-27
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper userMapper;



    @Override
    public User addUser(User user) {
        return null;
    }

    @Override
    public Integer deleteUserById(Integer id) {

        int i = userMapper.deleteById(id);
        return i;
    }

    @Override
    public Integer updateUserById(User user) {
        int i = userMapper.updateById(user);
        return i;
    }

    @Override
    public User selectOneUserById(Integer id) {
        return null;
    }

    @Override
    public List<User> selectAllUserByConditionws(String ziduan,String conditions) {
        QueryWrapper<User> queryWrapper=new QueryWrapper<>();
        queryWrapper.like(ziduan,conditions);
        List<User> users = userMapper.selectList(queryWrapper);
        return users;
    }

    @Override
    public List<User> selectAllUsers() {
        return userMapper.selectList(null);
    @Autowired
    private UserMapper userMapper;

    @Override
    public User getUserByUsname(String usName) {
        QueryWrapper<User> queryWrapper = new QueryWrapper();
        queryWrapper.eq("us_name",usName);

        return userMapper.selectOne(queryWrapper);
    }
}
